home *** CD-ROM | disk | FTP | other *** search
/ Java 1.1 Unleashed (3rd Edition) / Java 1.1 Unleashed Third Edition (1997)(SAMS.net)(Version 1.0).ISO / pc / 3rdparty / java / jamba / dev / jambaobj.awx / TEMPLATE / TBMPOBJ.JAVA < prev    next >
Encoding:
Text File  |  1996-07-15  |  5.9 KB  |  251 lines

  1. $$IF(JAMBA_EXPLCOMMENTS)
  2. /**
  3. * Jamba code template for $$JAMBA_CLASSNAME$$Obj
  4. * tbmpobj.java
  5. */
  6. $$ENDIF
  7. // All Jamba objects are located in the objects package
  8. package Aimtech.objects;
  9.  
  10. // Standard Jamba imports
  11. import java.lang.*;
  12. import java.awt.*;
  13. import java.util.*;
  14. import Aimtech.utils.*;
  15. import Aimtech.effects.*;
  16. import Aimtech.smartpage.*;
  17.  
  18. $$IF(JAMBA_EXPLCOMMENTS)
  19. /**
  20. * Implementation of Jamba $$JAMBA_CLASSNAME$$Obj object
  21. */
  22. $$ENDIF
  23. public class $$JAMBA_CLASSNAME$$Obj extends BitmappedObj
  24. {
  25.     // Used in objStart to check if previously stopped
  26.     private boolean bStopped = false;
  27.  
  28. $$IF(JAMBA_EXPLCOMMENTS)
  29.     /**
  30.     * Called once, and only once, when object is first loaded. Use
  31.     * to perform one time object initialization
  32.     */
  33. $$ENDIF
  34.     public void objLoad ()
  35.     {
  36. $$IF(JAMBA_TODOCOMMENTS)
  37.         //# TODO - Insert custom code here
  38. $$ENDIF
  39.         super.objLoad();
  40.     }
  41. $$IF(JAMBA_EXPLCOMMENTS)
  42.     /**
  43.     * Called each time the Jamba page containing the object is displayed. Use
  44.     * to allocate object resources. These resources should be freed in
  45.     * objFlush
  46.     */
  47. $$ENDIF
  48.     public final void objPrepare()
  49.     {
  50. $$IF(JAMBA_TODOCOMMENTS)
  51.         //# TODO - Insert custom code here
  52. $$ENDIF
  53.         super.objPrepare();
  54.     }
  55. $$IF(JAMBA_EXPLCOMMENTS)
  56.     /**
  57.     * Called each time the Jamba page containing the object is removed from
  58.     * the list of recently accessed Jamba pages. Use to free resources
  59.     * allocated by object.
  60.     */
  61. $$ENDIF
  62.     public void objFlush()
  63.     {
  64. $$IF(JAMBA_TODOCOMMENTS)
  65.         //# TODO - Insert custom code here
  66. $$ENDIF
  67.         super.objFlush();
  68.     }
  69. $$IF(JAMBA_EXPLCOMMENTS)
  70.     /**
  71.     * Called in response to several events including the object being made
  72.     * visible and the HTML page containing the object being redisplayed.
  73.     */
  74. $$ENDIF
  75.     public void objStart()
  76.     {
  77.         // If object stopped by objStop(), restart it here
  78.         if (bStopped)
  79.         {
  80.             bStopped = false;
  81. $$IF(JAMBA_TODOCOMMENTS)
  82.             //# TODO - Insert custom code here
  83. $$ENDIF
  84.         }
  85.  
  86.         super.objStart();
  87.     }
  88. $$IF(JAMBA_EXPLCOMMENTS)
  89.     /**
  90.     * Called in response to several events including the object being made
  91.     * not visible and the HTML page containing the object being changed
  92.     * within a web browser such that another HTML page can be displayed.
  93.     * Use to cease any ongoing object activity.
  94.     */
  95. $$ENDIF
  96.     public void objStop()
  97.     {
  98.         if (!bStopped)
  99.         {
  100. $$IF(JAMBA_TODOCOMMENTS)
  101.             //# TODO - Insert custom code here
  102. $$ENDIF
  103.               bStopped = true;
  104.         }
  105.  
  106.         super.objStop();
  107.     }
  108. $$IF(JAMBA_EXPLCOMMENTS)
  109.     /**
  110.     * Called to check if the object is dirty and needs to be repainted. This
  111.     * is used to minimize drawing of bitmapped objects.
  112.     */
  113. $$ENDIF
  114.     public synchronized boolean objNeedsPaint ()
  115.     {
  116. $$IF(JAMBA_TODOCOMMENTS)
  117.         //# TODO - Insert custom code here
  118. $$ENDIF
  119.         return (super.objNeedsPaint ());
  120.     }
  121. $$IF(JAMBA_EXPLCOMMENTS)
  122.     /**
  123.     * Called when the object needs to repaint itself. The painting is done
  124.     * to an the offscreen bitmapped used for double-buffering.
  125.     */
  126. $$ENDIF
  127.     public synchronized void objPaint (Graphics g)
  128.     {
  129.         // Use local Graphics so as not to modify that passed in.
  130.         Graphics drawG = g.create();
  131.  
  132.         // Do common bitmapped object drawing
  133.         super.objPaint(g);
  134.  
  135.         // Clip to the geometry of the object
  136.         drawG.clipRect (geo.x,geo.y,geo.width,geo.height);
  137.  
  138. $$IF(JAMBA_TODOCOMMENTS)
  139.         //# TODO - Insert custom code here.
  140. $$ENDIF
  141.         drawG.drawString ("Object Is Alive", geo.x + 10, geo.y + 20);
  142.  
  143.         // Allow local Graphics to be freed
  144.         drawG.dispose();
  145.  
  146.         // No longer need to be repainted
  147.         bNeedsPaint = false;
  148.     }
  149. $$IF(JAMBA_EXPLCOMMENTS)
  150.     /**
  151.      * Called when object properties are set or changed
  152.      */
  153. $$ENDIF
  154.     public synchronized void objSetProp(String name, String value)
  155.     {
  156.         if (name.equals("property1"))
  157.         {
  158. $$IF(JAMBA_TODOCOMMENTS)
  159.             //# TODO - Insert custom code here
  160. $$ENDIF
  161.         }
  162.  
  163.         else if (name.equals("property2"))
  164.         {
  165. $$IF(JAMBA_TODOCOMMENTS)
  166.             //# TODO - Insert custom code here
  167. $$ENDIF
  168.         }
  169.  
  170.         // Default property handling
  171.         else super.objSetProp(name, value);
  172.  
  173.         // If a runtime property change force an update.
  174.         if (bPrepared)
  175.             objRepaint();
  176.     }
  177. $$IF(JAMBA_EXPLCOMMENTS)
  178.     /**
  179.     * Called to retrieve the current value of an object property.
  180.     */
  181. $$ENDIF
  182.     public synchronized String objGetProp(String name)
  183.     {
  184.         
  185.         // If object does not track a property value in member variables or
  186.         // does not modify properties without updating the object's property
  187.         // list, it can simply allow the default property handling to occur
  188.         // and not have a case for it in the following code
  189.         if (name.equals("property1"))
  190.         {
  191. $$IF(JAMBA_TODOCOMMENTS)
  192.             //# TODO - Insert custom code here
  193. $$ENDIF
  194.         }
  195.  
  196.         else if (name.equals("property2"))
  197.         {
  198. $$IF(JAMBA_TODOCOMMENTS)
  199.             //# TODO - Insert custom code here
  200. $$ENDIF
  201.         }
  202.  
  203.         return (super.objGetProp(name));
  204.     }
  205. $$IF(JAMBA_EXPLCOMMENTS)
  206.     /**
  207.     * Called when an object methods has been called within a ToDo list.
  208.     */
  209. $$ENDIF
  210.     public synchronized boolean objDoMethod(String method, Vector args)
  211.     {
  212.         if (method.equals ("method1"))
  213.         {
  214. $$IF(JAMBA_TODOCOMMENTS)
  215.             //# TODO - Insert custom code here
  216. $$ENDIF
  217.         }
  218.         else if (method.equals ("method2"))
  219.         {
  220. $$IF(JAMBA_TODOCOMMENTS)
  221.             //# TODO - Insert custom code here
  222. $$ENDIF
  223.         }
  224.         else
  225.         {
  226.             return (super.objDoMethod(method, args));
  227.         }
  228.  
  229.         // Force an update
  230.         objRepaint();
  231.  
  232.         // The method was handled
  233.         return (true);
  234.     }
  235. $$IF(JAMBA_EXPLCOMMENTS)
  236.     /**
  237.     * Called in response to mouse events to determine if the specified point is a
  238.     * hot spot on the object. This can be used by objects to make transparent pieces
  239.     * not active.
  240.     */
  241. $$ENDIF
  242.     public boolean objIsHotSpot (Point pt)
  243.     {
  244. $$IF(JAMBA_TODOCOMMENTS)
  245.         //# TODO - Insert custom code here
  246. $$ENDIF
  247.         return (true);
  248.     }
  249. }
  250.  
  251.